package com.geekaca.d06;

import java.util.HashSet;
import java.util.Set;

public class TestHash {
    public static void main(String[] args) {
        /**
         * Hash
         */
//        String str ="Hello";
//        System.out.println(str.hashCode());
//        System.out.println("Java".hashCode());
//        System.out.println("Hello".hashCode());
        testCustom();
    }

    public static void testCustom(){
        /**
         * 目标:
         * 把学生对象放打入Set集合
         * 如何实现 去除重复?
         * Student 对象, 重复定义为:
         * name和ID相等,就认为是同一个学生
         *
         */

        Student stud1  =new Student("Tom", "56565656565");
        Student stud2  =new Student("Tom", "56565656565");
        Student stud3  =new Student("Jack", "56565656599");
        Set<Student> studentSet = new HashSet<>();
        studentSet.add(stud1);
        studentSet.add(stud2);
        studentSet.add(stud3);

//        System.out.println(studentSet);
        studentSet.forEach(item-> {
            System.out.print(item+ "hash: " + item.hashCode());
            System.out.println();
        });
    }
}
